< previous page page_122 next page >

Page 122
HRESULT value. That means we'll define the return type as a Long and remember that the result can be raised directly as an error if it is not 0.
Now to the parameters:
The rclsid parameter is a pointer to the CLSID structure to convert into a string.
The ppsz parameter is a bit trickier. If the parameter were an LPOLESTR, it would be a pointer to an OLE string or a wide (Unicode) string. But there's an extra * character, indicating that this is a pointer to a pointer to a string. At first guess, you might consider trying to pass a string by reference, especially since you know that Visual Basic stores strings internally as Unicode data.
That would lead you to the following code:
' GUID Puzzle Example Class
' Copyright © 1998 by Desaware Inc. All Rights Reserved

Public Type CLSID
   Data1 As Long
   Data2 As Integer
   Data3 As Integer
   Data4(7) As Byte
End Type

Private Declare Function CLSIDFromProgID Lib "ole32.dll" _
(ByVal lpszProgId As Long, lpclsid As CLSID) As Long
Private Declare Function StringFromCLSID Lib "ole32.dll" _
(lpclsid As CLSID, lpOlestr As String) As Long

Option Explicit

Public Function GetCLSIDAsString() As String
   Dim cid As CLSID
   Dim MyString As String

   cid = GetCLSID()

   Call StringFromCLSID(cid, MyString)
   GetCLSIDAsString = MyString
End Function

 
< previous page page_122 next page >